<template>
	<view>
		<view class="pos-real">
			<u-navbar title="充值总资产" :background="{ backgroundColor: 'transparent' }" :borderBottom="false"
				titleColor="#fff" backIconColor="#fff"></u-navbar>
			<image src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/czmximg.png"
				mode="scaleToFill" style="width: 100%; height: 500rpx;" class="pos-abs-lt"></image>
			<view class="mg-base" @click="SelectStoreShow = true">
				<view class="uni-flex justify-between align-center"
					style="height: 88rpx;background-color: white;width: 100%;position: relative;border-radius: 14rpx;">
					<view class="uni-flex align-center" style="margin-left: 15rpx;" @click="SelectStoreShow = true">
						<marquee-scroll width="160rpx">
							<view>
								<text class="mg-r-xs"
									style="font-weight: 600;">{{storeOption[selectedStoreIdx].name}}</text>
								<u-icon name="arrow-down"></u-icon>
							</view>
						</marquee-scroll>

						<view style="margin-left: 10rpx;background-color: #FF7D66;height: 48rpx;width: 1rpx;"></view>
						<view style="margin-left: 20rpx;width: 400rpx;">
							<u-input @click="SelectStoreShow = true" placeholder="快速搜索想查询的门店"
								v-model="keyword"></u-input>
						</view>
					</view>
					<view style="margin-right: 30rpx;" @click="keywordSeach">
						<image style="width: 40rpx;height: 40rpx;"
							src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/czmx-sousuo.png">
						</image>
					</view>
				</view>
			</view>

			<view class="mg-base">
				<image style="position: absolute;width: 680rpx;height: 206rpx;"
					src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/czmx-02img.png">
				</image>
				<view style="position: relative;">
					<view style="height: 206rpx;" class="uni-flex justify-around align-center">
						<view class="uni-flex uni-column align-center">
							<view class="uni-flex">
								<view>
									<image style="width: 60rpx;height: 60rpx;"
										src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/czmx-qb.png">
									</image>
								</view>
								<view>账户余额</view>
							</view>
							<view>
								<text
									style="font-size: 38rpx; font-weight: 600;">￥{{(packageAccount.amount/100).toFixed(2)}}</text>
							</view>
						</view>
						<view style="width: 2rpx;height: 62rpx;background-color: #979797;"></view>
						<view class="uni-flex uni-column align-center">
							<view class="uni-flex" @click="onNavDisCountList()">
								<view>
									<image style="width: 60rpx;height: 60rpx;"
										src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/czmx-yhq.png">
									</image>
								</view>
								<view>优惠券> </view>
							</view>
							<view>
								<text style="font-size: 38rpx; font-weight: 600;">{{(packageAccount.disCount)}}张</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mg-base" style="margin-top: 60rpx;">
			<view style="border-radius: 14rpx;">
				<u-tabs :list="tabs" active-color="#fff" :active-item-style="activeItemStyle" :current="tabIdx"
					:is-scroll="false" :show-bar="false" @change="handleTabChange"></u-tabs>
			</view>
		</view>
		<view class="mg-base">
			<view class="uni-flex justify-between align-center">
				<view @click="timeShow = true">
					<text style="font-size: 32rpx;font-weight: 600;">
						{{selectDate.format('yyyy年M月')}}>
					</text>
				</view>
				<view>
					<text style="color: #999999;">
						余额￥{{(topUpCount/100||0).toFixed(2)}} 消费￥{{(consumeCount/100||0).toFixed(2)}}
					</text>
				</view>
			</view>
		</view>
		<view class="mg-base" v-if="tabIdx==0">
			<view style="margin-bottom: 20rpx;" v-for="(item,index) in topUpDetail" :key="index">
				<view style="height: 90rpx;background-color: #FFFBF6;border-radius: 14rpx 14rpx 0rpx 0rpx;">
					<view class="uni-flex justify-between align-center"
						style="height: 100%;margin: 0rpx 10rpx 0rpx 10rpx;">
						<view>
							<text style="color: #666666;"
								@click="getStoreList(item.storeIds)">可用门店：{{item.storeId[0].name}}></text>
						</view>
						<view style="border: 1rpx solid #FF7D66;" class="uni-flex justify-around">
							<text style="font-size: 24rpx;color: #FF7D66;">·</text>
							<text style="font-size: 24rpx;color: #FF7D66;">{{(item.storeIds).length}}店通用</text>
							<text style="font-size: 24rpx;color: #FF7D66;">·</text>
						</view>
					</view>
				</view>
				<view style="background-color: white;height: 160rpx;border-radius: 0rpx 0rpx 14rpx 14rpx ;">
					<view class="uni-flex justify-between align-center"
						style="height: 100%;margin-left: 20rpx;margin-right: 10rpx;">
						<view>
							<view v-if="item.type==0">
								<marquee-scroll width="350rpx">
									<text
										style="font-size: 36rpx">{{item.chargeOffList[0].packageName||'-'}}</text>
								</marquee-scroll>
							</view>

							<view v-else class="uni-flex align-center">
								<marquee-scroll width="350rpx">
									<view>
										<text
											style="font-size: 36rpx">{{item.chargeOffList[0].packageName||'-'}}</text>
									</view>
								</marquee-scroll>

								<view style="margin-left: 10rpx;color: #FF7D66;" @click="onNavTopUpList(item)">查看>
								</view>
							</view>
							<view style="color: #666666;"><uni-dateformat :date="item.createTime"></uni-dateformat>
							</view>
						</view>
						<view v-if="item.type==0" class="uni-flex uni-column align-end">
							<text
								style="color: #FE5C47;font-size: 36rpx;font-weight: 600;">+{{((item.chargeOffList[0].packageGiveAmount+item.chargeOffList[0].packageTopupAmount)/100).toFixed(2)}}</text>
							<view style="color: #666666;">剩余：{{(item.packageUserId[0].packageAmount/100).toFixed(2)}}
							</view>
						</view>
						<view v-else>
							<text
								style="color: #FE5C47;font-size: 36rpx;font-weight: 600;">+{{getDisCountNum(item.packageUserId)}}张</text>
						</view>
					</view>
				</view>
			</view>
			<view style="margin-bottom: 20rpx;" v-for="(item,index) in topUpDetailExpire" :key="index">
					<view style="height: 90rpx;background-color: rgb(235, 235, 235);border-radius: 14rpx 14rpx 0rpx 0rpx;">
						<view class="uni-flex justify-between align-center"
							style="height: 100%;margin: 0rpx 10rpx 0rpx 10rpx;">
							<view>
								<text style="color: #666666;"
									@click="getStoreList(item.storeIds)">可用门店：{{item.storeId[0].name}}></text>
							</view>
							<view style="border: 1rpx solid #FF7D66;" class="uni-flex justify-around">
								<text style="font-size: 24rpx;color: #FF7D66;">·</text>
								<text style="font-size: 24rpx;color: #FF7D66;">{{(item.storeIds).length}}店通用</text>
								<text style="font-size: 24rpx;color: #FF7D66;">·</text>
							</view>
						</view>
					</view>
					<view style="background-color: rgb(235, 235, 235);height: 160rpx;border-radius: 0rpx 0rpx 14rpx 14rpx ;">
						<view class="uni-flex justify-between align-center"
							style="height: 100%;margin-left: 20rpx;margin-right: 10rpx;">
							<view>
								<view v-if="item.type==0">
									<marquee-scroll width="350rpx">
										<text
											style="font-size: 36rpx">{{item.chargeOffList[0].packageName||'-'}}</text>
									</marquee-scroll>
								</view>
			
								<view v-else class="uni-flex align-center">
									<marquee-scroll width="350rpx">
										<view>
											<text
												style="font-size: 36rpx">{{item.chargeOffList[0].packageName||'-'}}</text>
										</view>
									</marquee-scroll>
								</view>
								<view style="color: #666666;"><uni-dateformat :date="item.createTime"></uni-dateformat>
								</view>
							</view>
							<view v-if="item.type==0" class="uni-flex uni-column align-end">
								<text
									style="color: #FE5C47;font-size: 36rpx;font-weight: 600;">+{{((item.chargeOffList[0].packageGiveAmount+item.chargeOffList[0].packageTopupAmount)/100).toFixed(2)}}</text>
								<view style="color: #666666;">剩余：{{(item.packageUserId[0].packageAmount/100).toFixed(2)}}
								</view>
							</view>
							<view v-else>
								<text
									style="color: #FE5C47;font-size: 36rpx;font-weight: 600;">+{{getDisCountNum(item.packageUserId)}}张</text>
							</view>
						</view>
					</view>
				</view>
			
		</view>
		<view class="mg-base" v-if="tabIdx==1" style="width: 90%;">
			<uni-list>
				<uni-list-item v-for="(item, index) in consumeDetail" :key="index" :showArrow="false" :clickable="false"
					v-if="item.countDisCountNum!=0">
					<view class="h-box" style="width: 100%;">
						<view v-if="item.type==0" class="uni-flex justify-between align-center" style="width: 100%;">
							<view>
								<view>
									<text v-if="item.detailType==2" style="font-size: 36rpx;">过期充值礼包</text>
									<text v-else style="font-size: 36rpx;">门店核销金额</text>
								</view>
								<text v-if="item.detailType!=2">核销门店：{{item.storeId[0].name}}</text>
								<view style="color: #666666;"><uni-dateformat :date="item.createTime"></uni-dateformat>
								</view>
							</view>
							<view style="color: #FE5C47;font-size: 36rpx;font-weight: 600;">
								-{{(item.countAmount/100).toFixed(2)}}</view>
						</view>

						<view v-else class="uni-flex justify-between align-center" style="width: 100%;">
							<view>
								<view class="uni-flex align-center">
									<view v-if="item.detailType==2"><text style="font-size: 36rpx;">过期充值礼包</text></view>
									<view v-else><text style="font-size: 36rpx;">门店核销抵扣券</text></view>
									<view style="margin-left: 10rpx;" @click="onNavConsumeList(item)"><text
											style="font-size: 30rpx;color: #FF7D66;">查看></text></view>
								</view>
								<view v-if="item.detailType!=2" style="color: #666666;">核销门店：{{item.storeId[0].name}}
								</view>
								<view style="color: #666666;"><uni-dateformat :date="item.createTime"></uni-dateformat>
								</view>
							</view>
							<view style="color: #FE5C47;font-size: 36rpx;font-weight: 600;">
								-{{item.countDisCountNum}}张</view>
						</view>
					</view>
				</uni-list-item>
			</uni-list>
		</view>
		<u-popup v-model="storeListShow" mode="bottom" length="50%" border-radius="14" @close="storeListShowclose()">
			<view class="mg-base">
				<view>
					<view class="uni-flex justify-between align-center">
						<view><text style="font-size: 32rpx; font-weight: 600;">可用门店{{(storeListPopup).length}}家</text>
						</view>
						<view>
							<image style="width: 30rpx;height: 30rpx;"
								src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/删除2@2x.png">
							</image>
						</view>
					</view>
				</view>
				<view>
					<view v-for="(item,index) in storeListPopup" :key="index">
						<image
							src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/czmx-mendian.png"
							mode="scaleToFill" style="width: 100%; height: 66rpx;position: absolute;"></image>
						<view style="position: relative;margin-top: 20rpx;;margin-left: 80rpx;padding-top: 10rpx;">
							<text style="font-size: 28rpx">{{item.name}}</text>
						</view>
					</view>
				</view>
			</view>
		</u-popup>


		<u-popup v-model="SelectStoreShow" mode="bottom" length="50%" border-radius="14" @close="storeListShowclose()">

			<view class="uni-flex justify-between mg-base">
				<view @click="clearHandleStoreChange()">取消</view>
				<view style="font-size: 34rpx;font-weight: 600;">店铺切换</view>
				<view style="color: #FF9F43;" @click="handleStoreChange()">确定</view>
			</view>
			<view class="uni-flex mg-base align-center justify-between">
				<view class="uni-flex"
					style="width: 90%;padding-right: 10rpx;border-radius: 14rpx;background-color: rgb(245, 245, 245);">
					<view style="margin-left: 10rpx;margin-right: 10rpx;">
						<image style="width: 36rpx;height: 34rpx;"
							src="https://7463-tcb-rxeszamj94676b-6d6j813d8fcf0-1303238310.tcb.qcloud.la/static/img/mdqh-ss.png">
						</image>
					</view>
					<u-input :placeholderStyle="placeholderStyle" :customStyle="inputStyle" v-model="keyword"
						placeholder="快速搜索想要查询的门店"></u-input>
				</view>
				<view @click="keywordSeach()">搜索</view>
			</view>
			<view style="margin-bottom: 20rpx;">
				<picker-view v-if="true" :value="selectValue" @change="bindChange" class="picker-view"
					style="padding: 0rpx;!important">
					<picker-view-column>
						<view class="item" style="font-size: 36rpx;" v-for="(item,index) in storeOption" :key="index">
							{{item.name}}
						</view>
					</picker-view-column>
				</picker-view>
			</view>

		</u-popup>

		<u-popup v-model="timeShow" mode="bottom" length="50%" border-radius="14" @close="storeListShowclose()">
			<view class="uni-flex justify-between mg-base">
				<view @click="timeShow = false">取消</view>
				<view style="color: #FF9F43;" @click="onTimeShow">完成</view>
			</view>
			<picker-view :value="time" @change="timebindChange" class="picker-view">
				<picker-view-column>
					<view class="item" v-for="(item,index) in years" :key="index">{{item}}年</view>
				</picker-view-column>
				<picker-view-column>
					<view class="item" v-for="(item,index) in months" :key="index">{{item}}月</view>
				</picker-view-column>
			</picker-view>
		</u-popup>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	import {
		getUserInfo,
		getUserPackageSearch,
		getPackageProperty
	} from "@/api/platform/user.js";
	import {
		genPackageOrder,
		genPayInfo,
		updatePakcageState
	} from "@/api/platform/order.js";
	import moment from 'moment';
	const db = uniCloud.database()
	export default {
		data() {
			return {
				placeholderStyle: "color: '#999999'",
				inputStyle: {
					color: '#999999',
					"text-align": "left"
				},
				selectedStoreIdx: 0,
				storeList: null,
				keyword: '',
				tabIdx: 0,
				tabs: [{
					name: '充值明细',
					list: [],
					loadingStatus: 'more'
				}, {
					name: '消费明细',
					list: [],
					loadingStatus: 'more'
				}],
				activeItemStyle: {
					backgroundColor: '#FF7D66',
					border: '2px solid #fff',
					borderRadius: '40rpx'
				},
				topUpDetail: [],
				topUpDetailExpire: [],
				consumeDetail: [],
				packageAccount: {
					amount: 0,
					disCount: 0
				},
				storeListShow: false,
				SelectStoreShow: false,
				timeShow: false,
				storeListPopup: [],
				selectValue: [],
				time: [],
				listTime: '',
				years: [],
				year: '',
				months: [],
				month: '',
				topUpCount: 0,
				consumeCount: 0,
				oldStoreIdx: 0,
				selectDate: this.$moment()
			}
		},
		computed: {
			...mapState(["updateUserInfo", "userInfo"]),

			storeOption() {
				return [{
					name: '全部门店',
					_id: ''
				}].concat(this.storeList || [])
			}
		},
		onLoad(e) {
			this.selectDate = this.selectDate.date(1).hour(0).minute(0).second(0).millisecond(0);
			//console.log("this.selectDate",this.selectDate)
			const date = new Date()
			this.year = date.getFullYear()
			this.month = date.getMonth() + 1
			for (let i = 1990; i <= date.getFullYear(); i++) {
				this.years.push(i)
			}
			for (let i = 1; i <= 12; i++) {
				this.months.push(i)
			}
			this.listTime = this.year + "年" + this.month + "月"
			this.time = [this.years.length - 1, this.month - 1]
			console.log("onload", this.time)
		},
		async onReady() {
			uni.showLoading({
				mask: true
			})
			await this.getData()
			uni.hideLoading()
		},
		async onPullDownRefresh() {
			await this.getData();
			uni.stopPullDownRefresh();
		},
		methods: {
			getTime() {
				var times = []
				let d = this.$moment(this.selectDate)
				var timestamp = d.date(1).hour(0).minute(0).second(0).millisecond(0).toDate().getTime()
				var lastDay = d.add(1, 'month').add(-1, 'second').toDate().getTime()
				times.push(timestamp)
				times.push(lastDay)
				console.log(times)
				return times
			},
			async loadStoreList() {
				if (this.storeList) {
					return
				}
				this.storeList = await this.$dbHelper.getList('t3ds-store', {
					field: '_id,name'
				})
				console.log(this.storeList)
			},
			async loadAccountPackageInfo() {
				this.packageAccount = {
					amount: 0,
					disCount: 0
				}
				const dbCmd = db.command
				const $ = dbCmd.aggregate
				console.log("this.storeOption[this.selectedStoreIdx]", this.storeOption[this.selectedStoreIdx])
				//console.log(this.selectedStoreIdx != 0 ? [this.storeOption[this.selectedStoreIdx]._id] : [])

				let amount = await db.collection('t3ds-package-user').aggregate().match({
						uid: this.userInfo._id,
						delFlag: 0,
						type: 0,
						storeIds: this.selectedStoreIdx == 0 ? db.command.exists(true) : dbCmd.in([this
							.storeOption[this.selectedStoreIdx]._id
						])
					})
					.project({
						packageAmount: 1
					})
					.group({
						_id: 1,
						totalCount: $.sum('$packageAmount')
					})
					.end()

				let disCount = await db.collection('t3ds-package-user').aggregate().match({
						uid: this.userInfo._id,
						delFlag: 0,
						type: 1,
						storeIds: this.selectedStoreIdx == 0 ? db.command.exists(true) : dbCmd.in([this
							.storeOption[this.selectedStoreIdx]._id
						])
					})
					.project({
						discountCoupon: 1
					})
					.addFields({
						totalNum: $.sum('$discountCoupon.num')
					}).project({
						totalNum: 1
					}).group({
						_id: 1,
						totalCount: $.sum('$totalNum')
					})
					.end()
				if (amount.result.data.length > 0) {
					this.packageAccount.amount = amount.result.data[0].totalCount
				}
				if (disCount.result.data.length > 0) {
					this.packageAccount.disCount = disCount.result.data[0].totalCount
				}
				console.log("amount", amount)
				console.log("disCount", disCount)
			},
			async loadPackageMoneyCount() {
				this.topUpCount = 0;
				this.consumeCount = 0;
				console.log("", this.year + "-" + this.month + "-01 00:00:00")
				//let d = this.$moment(this.selectDate)

				const dbCmd = db.command
				const $ = dbCmd.aggregate
				var time = this.getTime()
				var where = {
					uid: this.userInfo._id,
					detailType: 0,
					createTime: dbCmd.and(dbCmd.gt(time[0]), dbCmd.lt(time[1]))
				}

				if (this.selectedStoreIdx != 0) {
					where.storeId = dbCmd.in([this.storeOption[this.selectedStoreIdx]._id])
				}
				let consumeSum = await db.collection('t3ds-package-log').aggregate()
					.match(where)
					.project({
						countAmount: 1
					})
					.group({
						_id: 1,
						totalCount: $.sum('$countAmount')
					})
					.end()
				var match = {
					uid: this.userInfo._id,
					type: 0,
					createTime: dbCmd.and(dbCmd.gt(time[0]), dbCmd.lt(time[1]))
				}
				if (this.selectedStoreIdx != 0) {
					match.storeIds = dbCmd.in([this.storeOption[this.selectedStoreIdx]._id])
				}
				let amount = await db.collection('t3ds-package-user').aggregate().match(match)
					.project({
						packageTopupAmount: $.sum(["$packageAmount"]),
					})
					.group({
						_id: 1,
						totalCount: $.sum('$packageTopupAmount')
					}).end()

				//console.log("amount1111", amount)
				if (consumeSum.result.data[0]) {
					this.consumeCount = consumeSum.result.data[0].totalCount;
				}
				if (amount.result.data[0]) {
					this.topUpCount = amount.result.data[0].totalCount;
				}
				console.log("consumeSum", consumeSum)
				console.log("amount", amount.result)
			},
			async loadPackageDetailList(name) {
				const dbCmd = db.command
				const $ = dbCmd.aggregate
				this.topUpDetail = []
				this.consumeDetail = []
				this.topUpDetailExpire = []
				var time = this.getTime()
				// console.log("timestamp", timestamp)
				// console.log("lastDay", lastDay)
				if (this.tabIdx == 0) {
					var where = {
						uid: this.userInfo._id,
						detailType: 1,
						createTime: dbCmd.and(dbCmd.gt(time[0]), dbCmd.lt(time[1]))
					}

					if (this.selectedStoreIdx != 0) {
						where.storeIds = dbCmd.in([this.storeOption[this.selectedStoreIdx]._id])
					}
					console.log("where", where)
					db.collection('t3ds-package-log,t3ds-store,t3ds-package-user')
						.where(where).field(
							'packageTopupAmount,packageName,chargeOffList,packageGiveAmount,packageUserId,storeId,storeIds,type,discountCoupon,createTime,consumeDetail'
						).orderBy('createTime desc').get().then(res => {

							for (var i = 0; i < res.result.data.length; i++) {
								if (res.result.data[i].packageUserId[0].delFlag == 1) {
									this.topUpDetailExpire.push(res.result.data[i])
								} else {
									this.topUpDetail.push(res.result.data[i])
								}

							}

							console.log("package1", this.topUpDetail)
							console.log("package2", this.topUpDetailExpire)
						})



				} else {
					var time = this.getTime()
					var where = {
						uid: this.userInfo._id,
						detailType: dbCmd.eq(0).or(dbCmd.eq(2)),
						createTime: dbCmd.and(dbCmd.gt(time[0]), dbCmd.lt(time[1]))
					}
					if (this.selectedStoreIdx != 0) {
						where.storeId = {
							_id: dbCmd.eq(this.storeOption[this.selectedStoreIdx]._id)
						}
					}
					console.log("where11", where)
					db.collection('t3ds-package-log,t3ds-store,t3ds-package-user')
						.where(where).field(
							'packageUserId,countDisCountNum,countAmount,storeId,detailType,type,discountCoupon,createTime,chargeOffAmount,packageUserId'
						).orderBy('createTime desc').get()
						.then(res => {
							this.consumeDetail = res.result.data;
							console.log("topUpDetail1", res)
						})
				}




			},
			async getData() {

				await this.loadStoreList();
				//获取账户余额和优惠券
				await this.loadAccountPackageInfo()
				//获取充值明细列表
				await this.loadPackageDetailList();
				await this.loadPackageMoneyCount()
			},

			clearHandleStoreChange() {
				this.selectedStoreIdx = this.oldStoreIdx

				this.SelectStoreShow = false
			},
			async handleStoreChange(e) {
				this.oldStoreIdx = this.selectedStoreIdx
				console.log(e)
				//this.selectedStoreIdx = e.detail.value
				uni.showLoading({
					mask: true
				})
				await this.getData()

				this.SelectStoreShow = false
				// this.$nextTick(() => {
				// 	this.reload()
				// })
				uni.hideLoading()
			},
			async handleTabChange(idx) {
				console.log(idx)
				this.tabIdx = idx
				uni.showLoading({
					mask: true
				})
				await this.getData()
				uni.hideLoading()

			},
			storeListShowclose() {

			},
			storeListShowopen() {

			},
			getStoreList(storeIdx) {
				const dbCmd = db.command
				const $ = dbCmd.aggregate
				db.collection('t3ds-store').where({
					_id: dbCmd.in(storeIdx)
				}).field("name").get().then(res => {
					this.storeListPopup = res.result.data;
					this.storeListShow = true
					//console.log("storeList",res)
				})
				// console.log(storeIdx)
			},
			keywordSeach() {
				db.collection('t3ds-store').where(`${new RegExp(this.keyword, 'i')}.test(name)`).field('_id,name').get()
					.then(res => {
						console.log("store", res.result.data)
						this.selectValue[0] = 0
						this.selectedStoreIdx = 0
						this.storeList = res.result.data;
					})
				this.$forceUpdate()
				console.log()
			},
			getDisCountNum(list) {
				let num = 0;
				list[0].discountCoupon.map(item => {
					num += item.num
				})
				return num;
			},
			onNavDisCountList() {
				console.log("this.selectedStoreIdx", this.selectedStoreIdx)
				if (this.selectedStoreIdx != 0) {
					uni.navigateTo({
						url: "disCountList?storeId=" + this.storeList[this.selectedStoreIdx - 1]._id
					})
				} else {
					uni.navigateTo({
						url: "disCountList"
					})
				}

			},

			onNavTopUpList(item) {
				console.log(item)

				uni.navigateTo({
					url: "consumeDetail?packageId=" + item.packageUserId[0]._id
				})
			},
			onNavConsumeList(item) {
				console.log(item)

				uni.navigateTo({
					url: "consumeDetail?packageLogId=" + item._id
				})
			},
			bindChange(item) {

				this.selectedStoreIdx = item.detail.value[0]
				// console.log(this.selectedStoreIdx)
				this.selectValue[0] = item.detail.value[0]
				console.log(this.selectValue)
			},
			timebindChange(item) {
				this.time = item.detail.value
				console.log("time", item);
			},
			onTimeShow() {
				console.log("this.time", this.time);
				this.selectDate.year(this.years[this.time[0]]).month(this.months[this.time[1]] - 1)
				// this.year = this.years[this.time[0]]
				// this.month = this.months[this.time[1]]
				this.timeShow = false;
				this.getData()
			}
		}
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}

	.picker-view {
		width: 750rpx;
		height: 600rpx;
		margin-top: 20rpx;
	}

	.item {
		text-align: center;
	}
</style>

<style lang="scss" scoped>
	/deep/ .u-sticky-wrap {
		background-color: #ffffff00 !important;
	}

	.top-bar {
		height: 88rpx;
		background-color: #fff;
		border-radius: 22rpx;
		padding: 0 20rpx;
		font-weight: 600;
	}

	.u-image {
		line-height: 1;
	}

	.link {
		border-radius: 12rpx;
		border: 2rpx solid rgba(255, 255, 255, 0.5);
		padding: 4rpx 20rpx;
		font-size: 24rpx;
	}

	.status-tag {
		height: 44rpx;
		line-height: 44rpx;
		border-radius: 22rpx;
		color: #fff;
		font-size: 24rpx;
		padding: 0 20rpx;
	}

	.status-pass {
		background: #FF7D66;
	}

	.status-reject {
		background: #FF7D66;
	}

	.status-pending {
		background: rgba(255, 159, 67, 0.22);
		border: 2rpx solid #FF9F43;
		color: #FF9F43;
	}

	.status-expired {
		background: rgba(216, 216, 216, 0.37);
		color: #A4A4A4;
	}

	.status-init {
		background: rgba(255, 125, 102, 0.30);
		border: 2rpx solid #FF7D66;
		color: #E54428;
	}

	.text-rewards {
		font-size: 30rpx;
		font-weight: 600;
		color: #FF8900;
	}

	.u-tabs {
		background: #EBEBEB !important;
		height: 100rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		padding: 0 30rpx;
		border-radius: 50rpx;
	}

	.uni-list {
		border-radius: 20rpx;
	}

	.integral-card {
		background-image: url(https://7463-tcb-zoumbaexjdidjmj2ff212-5d3479-1303238310.tcb.qcloud.la/static/img/bg-integral.png);
		background-size: 100% 100%;
		height: 272rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding: 30rpx;
		color: #fff;

		.text-integral-label {
			font-size: 28rpx;
		}

		.text-integral {
			font-size: 72rpx;
		}
	}

	.item-bottom {
		background: #FFFBF6;
		border-radius: 12rpx;
		padding: 20rpx;
		margin-top: 20rpx;
	}

	.item-bottom * {
		font-size: 24rpx;
	}

	.task-item {
		background-color: #fff;
		padding: 30rpx;
		margin-bottom: 30rpx;
		border-radius: 20rpx;
	}

	.task-item.expired {
		background-color: #EBEBEB;
	}
</style>